package Test2;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class button
{
    public static void main(String[] args) {
        JFrame jf = new JFrame();
        jf.setTitle("登录");
        jf.setSize(400,300);
        jf.setLocationRelativeTo(null);
        jf.setAlwaysOnTop( true);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //取消默认居中外置
        jf.setLayout(null);


        JButton jtb = new JButton("点我呀");
        jtb.setBounds(0,0,100,50);
        jtb.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("用户点击了按钮");
            }
        });
        jf.getContentPane().add(jtb);
        jf.setVisible(true);
    }
}
